var util = require('../../../../utils/util.js');
var api = require('../../../../config/api.js');
var app = getApp()
// pages/ucenter/help/help.js
Page({
  data:{
    userInfo: {},
    helpList: [],
    referralCode:null
  },
  codeInput: function (e) { 
    let that = this;
    this.setData({
      referralCode: e.detail.value,
    });
  },
  bindUser() {
    let that = this;
    util.request(api.RecommendSave, {referralCode:that.data.referralCode},).then(function (res) {
      if (res.errno === 0) {
        that.setData({
          helpList: res.data
        })
      }else {
        // util.showErrorToast(res.errmsg)
        wx.showModal({
          title: '提示',
          content: res.errmsg,
          showCancel: false
        });
      }


    });
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数 

  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    let userInfo = wx.getStorageSync('userInfo');
    let token = wx.getStorageSync('token');

    // 页面显示
    if (userInfo && token) {
      app.globalData.userInfo = userInfo;
      app.globalData.token = token;
    }

    this.setData({
      userInfo: app.globalData.userInfo,
    });
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})